/*
  Problem 1. Roundabount Rounding
  Description
    Bessie the cow is back in school! She has started doing her math homework
    in which she is tasked to round positive integers to powers of 10.

    To round a positive integer a to the nearest 10^b, where b is a positive
    integer, Bessie first locates the b'th digit from the right. Let x denote
    this digit.

    If x ≥ 5, Bessie adds 10^b to a.

    Then, Bessie sets all the digits including and to the right of the b'th digit
    from the right to be 0.

    For instance, if Bessie wanted to round 456 to the nearest 10^2 (hundred),
    Bessie would first locate the 2nd digit from the right which is 5. This means x = 5.
    Then since x ≥ 5, Bessie adds 100 to a. Finally, Bessie sets all the digits
    in a to the right of and including the 2nd digit from the right to be 0,
    resulting in 500.

    However, if Bessie were to round 446 to the nearest 10^2, she would end up with 400.

    After looking at Bessie's homework, Elsie thinks she has invented a new type
    of rounding: chain rounding. To chain round to the nearest 10^b, Elsie will
    first round to the nearest 10^1, then the nearest 10^2, and so on until the
    nearest 10^b.

    Bessie thinks Elsie is wrong, but is too busy with math homework to confirm
    her suspicions. She tasks you to count how many integers x at least 2 and
    at most N (1 ≤ N ≤ 10^9) exist such that rounding x to the nearest 10^P is
    different than chain rounding to the nearest 10^P, where P is the smallest
    integer such that 10^P ≥ x.

  INPUT FORMAT (input arrives from the terminal / stdin):
    You have to answer multiple test cases.

    The first line of input contains a single integer T (1 ≤ T ≤ 10^5) denoting
    the number of test cases. T test cases follow.

    The first and only line of input in every test case contains a single
    integer N. All N within the same input file are guaranteed to be distinct.

  OUTPUT FORMAT (print output to the terminal / stdout):
    Output T lines, the i'th line containing the answer to the i'th test case.
    Each line should be an integer denoting how many integers at least 2 and
    at most N exist that are different when using the two rounding methods.

  SAMPLE INPUT:
    4
    1
    100
    4567
    3366
  SAMPLE OUTPUT:
    0
    5
    183
    60
  hint:
    Consider the second test case in the sample. 48 should be counted because 48
    chain rounded to the nearest 10^2 is 100 (48 → 50 → 100), but 48 rounded to
    the nearest 10^2 is 0.

    In the third test case, two integers counted are 48 and 480. 48 chain rounds
    to 100 instead of to 0 and 480 chain rounds to 1000 instead of 0.
    However, 67 is not counted since it chain rounds to 100 which is 67 rounded
    to the nearest 10^2.

  SCORING:
    Inputs 2-4: N ≤ 103
    Inputs 5-7: N ≤ 106
    Inputs 8-13: No additional constraints.

  Problem credits: Weiming Zhou

  圆角舍入
  题目描述
    奶牛 Bessie 又回到学校了！她已经开始做数学作业了，她的任务是将正整数四舍五入到 10 的若干次方.

    对正整数 a 进行四舍五入到最近的 10^b，其中 b 是正整数。Bessie 首先找到从右边算起的第 b 位数字。
    假设 x 表示这个数字。

    如果 x ≥ 5，Bessie 将 10^b 加到 a 上, 即 a = a + 10^b。
    然后，Bessie 将从右边算起的第 1 ~ b 位上的数字设置为 0。

    例如:
      如果 Bessie 想要将 456 舍入到最接近的 10^2（百），
      Bessie 首先会找到从右边算起的第二个数字，即 5。这意味着 x = 5。
      然后，由于 x ≥ 5，Bessie 在 a 上加了 100, 得到 556。
      最后，Bessie 将 a 的右侧的所有数字（包括右侧第 2 个数字）设置为 0， 结果是 500。

    然而，如果 Bessie 将 446 四舍五入到最接近的 10^2，她最终会得到 400。

    看了 Bessie 的作业后，Elsie 认为她发明了一种新的进行 round 处理的方法：chain round。
    为了得到最接近的 10^b，Elsie 首先舍入到最接近的 10^1，然后舍入到最接近的 10^2，
    依此类推，直到最接近的 10^b。

    Bessie 认为 Elsie 错了，但正忙于数学作业，无法证实她的怀疑。
    她要求你进行如下统计:
      存在多少个整数 x (2 <= x <= n, 1 ≤ n ≤ 10^9), 按照 Elsie的方法和 Bessie 的方法
      分别对 x 进行 round 到 10^P 操作时最后的结果会不同？
      其中 P 是满足 10^P ≥ x 的最小整数。

  输入格式
    第一行一个整数 T (1 ≤ T ≤ 10^5), 表示后面会输入 T 个数
    后面有 T 行, 每一行为一个测试用例，每一行有一个整数 N. 保证同一输入文件中的所有 N 都是不同的。
  输出格式
    输出 T 行，第 i 行包含第 i 个测试用例的答案。
    每一行都应该是一个整数，表示使用两种舍入方法时存在多少个不同的整数（至少 2 个，最多 N 个）。
  样例
    输入:
      4
      1
      100
      4567
      3366
    输出:
      0
      5
      183
      60
    提示:
      考虑示例中的第二个测试用例。应该算48，因为48
      链四舍五入到最接近的 10^2 是 100 (48 → 50 → 100)，但 48 四舍五入到
      最接近的 10^2 是 0。

      在第三个测试用例中，计数的两个整数分别是 48 和 480。 48 链轮
      到 100 而不是 0，480 链舍入到 1000 而不是 0。
      然而，67 不被计算在内，因为它链式舍入到 100，即 67 舍入
      到最接近的 10^2。
  数据范围
    Inputs 2-4: N ≤ 103
    Inputs 5-7: N ≤ 106
    Inputs 8-13: 没有其他限制
*/